package com.homer.gps.track.helper;

import java.io.File;

import android.content.Context;
import android.os.AsyncTask;

public class SDLoader extends AsyncTask<String, Void, RecordedImage> {

    private Context context;
    private SDDataLoader mListener;

    public SDLoader(Context context, SDDataLoader listener) {
	this.context = context;
	this.mListener = listener;
    }

    @Override
    protected RecordedImage doInBackground(String... params) {
	String path = params[0];
	if (path.length() > 0) {
	    File image = new File(path);
	    return new RecordedImage(ImageHelper.decodeFile(image), path);
	}
	return null;
    }

    @Override
    protected void onPostExecute(RecordedImage result) {
	super.onPostExecute(result);
	if (mListener != null) {
	    mListener.onBitmapLoaded(result);
	}
    }

}
